import 'package:flutter/cupertino.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sleep/help_style.dart';
import 'package:sleep/provider/enter_provider.dart';

class Enter extends StatelessWidget {
  final Widget child;

  const Enter({super.key, required this.child});
  @override
  Widget build(BuildContext context) {
    return Consumer(
      builder: (context, ref, buildChild) {
        final cofig = ref.watch(configProvider);
        return cofig.when(
            data: (t) {
              if (t) {
                return child;
              }
              return Container();
            },
            error: (e, t) => const Text("Loading"),
            loading: () => Container(
                color: HelpStyle.backgroundColor,
                child: CupertinoActivityIndicator(
                    color: HelpStyle.primarycolor, radius: 20)));
      },
    );
  }
}
